package hibernate.p;

import java.util.StringTokenizer;
import java.lang.*;

public class TelNumber {
	//-1 indicates null
	private long nationCode=-1;
	private long provinceCode=-1;
	private long cityCode=-1;
	private long number=-1;
	
	private TelNumber(){}
	
	public TelNumber(long a,long b,long c,long d){
		this.setNationCode(a);
		this.setProvinceCode(b);
		this.setCityCode(c);
		this.setNumber(d);
	}
	
	public void setNationCode(long n){
		nationCode=n;
		nationCode=Math.max(nationCode, -1);
	}
	
	public long getNationCode(){
		return nationCode;
	}
	
	public void setProvinceCode(long n){
		provinceCode=n;
		provinceCode=Math.max(provinceCode, -1);
	}
	
	public long getProvinceCode(){
		return provinceCode;
	}
	
	public void setCityCode(long n){
		cityCode=n;
		cityCode=Math.max(cityCode, -1);
	}
	
	public long getCityCode(){
		return cityCode;
	}
	
	public void setNumber(long n){
		number=n;
		number=Math.max(number, -1);
	}
	
	public long getNumber(){
		return number;
	}
	
	public String toString(){
		return ""+nationCode+"\n"+provinceCode+"\n"+cityCode+"\n"+number;
	}
	
	public static TelNumber parseString(String code){
		TelNumber ret=new TelNumber();
		StringTokenizer st=new StringTokenizer(code,"\n");
		ret.nationCode=new Long(st.nextToken());
		ret.provinceCode=new Long(st.nextToken());
		ret.cityCode=new Long(st.nextToken());
		ret.number=new Long(st.nextToken());
		return ret;
	}
}
